package protocol

import "gitee.com/crack007/goose/helper"

var protocolMap = map[uint32]IProtocol{}

func RegisterProtocol(protocol IProtocol) {
	protocolMap[protocol.Code()] = protocol
}

func GetProtocol(code uint32) IProtocol {
	if v, ok := protocolMap[code]; ok {
		return helper.CloneInterface(v).(IProtocol)
	}
	return nil
}
